package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchMapMonitor;
import com.ruoyi.system.service.IDispatchMapMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地图监控Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchMapMonitor")
public class DispatchMapMonitorController extends BaseController
{
    @Autowired
    private IDispatchMapMonitorService dispatchMapMonitorService;

    /**
     * 查询地图监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchMapMonitor dispatchMapMonitor)
    {
        startPage();
        List<DispatchMapMonitor> list = dispatchMapMonitorService.selectDispatchMapMonitorList(dispatchMapMonitor);
        return getDataTable(list);
    }

    /**
     * 导出地图监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:export')")
    @Log(title = "地图监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchMapMonitor dispatchMapMonitor)
    {
        List<DispatchMapMonitor> list = dispatchMapMonitorService.selectDispatchMapMonitorList(dispatchMapMonitor);
        ExcelUtil<DispatchMapMonitor> util = new ExcelUtil<DispatchMapMonitor>(DispatchMapMonitor.class);
        util.exportExcel(response, list, "地图监控数据");
    }

    /**
     * 获取地图监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:query')")
    @GetMapping(value = "/{mapMonitorId}")
    public AjaxResult getInfo(@PathVariable("mapMonitorId") Long mapMonitorId)
    {
        return success(dispatchMapMonitorService.selectDispatchMapMonitorByMapMonitorId(mapMonitorId));
    }

    /**
     * 新增地图监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:add')")
    @Log(title = "地图监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchMapMonitor dispatchMapMonitor)
    {
        return toAjax(dispatchMapMonitorService.insertDispatchMapMonitor(dispatchMapMonitor));
    }

    /**
     * 修改地图监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:edit')")
    @Log(title = "地图监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchMapMonitor dispatchMapMonitor)
    {
        return toAjax(dispatchMapMonitorService.updateDispatchMapMonitor(dispatchMapMonitor));
    }

    /**
     * 删除地图监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchMapMonitor:remove')")
    @Log(title = "地图监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mapMonitorIds}")
    public AjaxResult remove(@PathVariable Long[] mapMonitorIds)
    {
        return toAjax(dispatchMapMonitorService.deleteDispatchMapMonitorByMapMonitorIds(mapMonitorIds));
    }
}
